<?php
if ( $is_print ) {
	header('Content-type: application/vnd.ms-excel');
	header('Content-Disposition: attachment; filename=' . $po_info['po_number'] .'.xls');
}
?>

<table style="{{ $text_calibri }} {{ $text_size_11 }}">
<!-- Header -->
<tr>
	<td colspan="3" rowspan="5">Company Logo</td>
	<td colspan="2" style="{{ $text_bold }}">{{ Lang::get('info.STORM.name') }}</td>
	<td colspan="4" rowspan="2" style="{{ $black_and_white }} {{ $text_middle }} {{ $text_center }} {{ $text_size_14 }}">{{ strtoupper($print_po_title) }}</td>
</tr>
<tr>
	<td colspan="2" rowspan="2" style="{{ $text_top }}">
	{{ Lang::get('info.STORM.building') }} <br/>
	{{ Lang::get('info.STORM.street') }} <br />
	{{ Lang::get('info.STORM.city') }} {{ Lang::get('info.STORM.postal') }}<br />
	</td>
</tr>
<tr><td colspan="9">&nbsp;</td></tr>
<tr>
	<td colspan="2">{{ $print_tel_fax_num }} {{ Lang::get('info.STORM.phone') }}</td>
	<td colspan="2" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_po_number }}</td>
	<td colspan="2" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_po_date }}</td>
</tr>
<tr>
	<td colspan="2">{{ $print_tin }} {{ Lang::get('info.STORM.tin') }}</td>
	<td colspan="2" style="{{ $border }} {{ $text_center }}">{{ $po_info['po_number'] }}</td>
	<td colspan="2" style="{{ $border }} {{ $text_center }}">{{ $po_info['po_date'] }}</td>
</tr>
<tr><td colspan="9">&nbsp;</td></tr>

<!-- Vendor and Sold To -->
<tr>
	<td colspan="4" style="{{ $black_and_white }} {{ $border }} {{ $text_center }}">{{ $print_vendor }}</td>
	<td colspan="1">&nbsp;</td>
	<td colspan="4" style="{{ $black_and_white }} {{ $border }} {{ $text_center }}">{{ $print_sold_to }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }}">{{ strtoupper($vendor->name) }}</td>
	<td colspan="1">&nbsp;</td>
	<td colspan="4" style="{{ $border_vertical }}">{{ strtoupper(Lang::get('info.STORM.name')) }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }}">{{ $vendor->address }}</td>
	<td colspan="1">&nbsp;</td>
	<td colspan="4" style="{{ $border_vertical }}">{{ Lang::get('info.STORM.building') }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }}"></td>
	<td colspan="1">&nbsp;</td>
	<td colspan="4" style="{{ $border_vertical }}">{{ Lang::get('info.STORM.street') }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }}"></td>
	<td colspan="1">&nbsp;</td>
	<td colspan="4" style="{{ $border_vertical }}">{{ Lang::get('info.STORM.city') }} {{ Lang::get('info.STORM.postal') }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }}">{{ $vendor->contact_person }}</td>
	<td colspan="1">&nbsp;</td>
	<td colspan="4" style="{{ $border_vertical }}">{{ Lang::get('info.STORM.contact_person') }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }} {{ $border_bottom }}">{{ $vendor->contact_number }}</td>
	<td colspan="1">&nbsp;</td>
	<td colspan="4" style="{{ $border_vertical }} {{ $border_bottom }}">{{ Lang::get('info.STORM.phone') }}</td>
</tr>
<tr><td colspan="9">&nbsp;</td></tr>

<!-- Shipping Details -->
<tr>
	<td colspan="4" style="{{ $black_and_white }} {{ $border }} {{ $text_center }}">{{ $print_shipping_address }}</td>
	<td></td>
	<td colspan="2" style="{{ $black_and_white }} {{ $border }} {{ $text_center }}">{{ $print_delivery_date }}</td>
	<td colspan="2" style="{{ $black_and_white }} {{ $border }} {{ $text_center }}">{{ $print_payment_terms }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }}">{{ $po_info['shipping_address']['unit'] }}</td>
	<td colspan="1" rowspan="3"></td>
	<td colspan="2" rowspan="3" style="{{ $text_center }} {{ $border }} {{ $text_top }}">{{ $po_info['delivery_date'] }}</td>
	<td colspan="2" rowspan="3" style="{{ $text_center }} {{ $border }} {{ $text_top }}">{{ $vendor->payment_type }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }}">{{ $po_info['shipping_address']['street'] }}</td>
</tr>
<tr>
	<td colspan="4" style="{{ $border_vertical }} {{ $border_bottom }}">{{ $po_info['shipping_address']['city'] }} {{ $po_info['shipping_address']['postal'] }}</td>
</tr>
<tr><td colspan="9">&nbsp;</td></tr>

<!-- Purchase Order Products -->
<tr>
	<td style="{{ $border }} {{ $black_and_white }} {{ $text_center }}">{{ $print_pr_number }}</td>
	<td style="{{ $border }} {{ $black_and_white }}  {{ $text_center }}">{{ $print_qty }}</td>
	<td colspan="4" style="{{ $border }} {{ $black_and_white }} {{ $text_center }}">{{ $print_particulars }}</td>
	<td style="{{ $border }} {{ $black_and_white }} {{ $text_center }}">{{ $print_item_code }}</td>
	<td style="{{ $border }} {{ $black_and_white }} {{ $text_center }}">{{ $print_unit_price }}</td>
	<td style="{{ $border }} {{ $black_and_white }} {{ $text_center }}">{{ $print_total }}</td>
</tr>
@foreach( $products as $item )
<tr>
	<td style="{{ $border }}">{{ $item['model'] }}</td>
	<td style="{{ $text_right }} {{ $border }}">{{ $item['quantity'] }}</td>
	<td colspan="4" style="{{ $border }}">
		{{ $item['name'] }}
		@if ( !empty( $item['options'] ) )
			<br/>
			@foreach( $item['options'] as $option )
				{{ $option['value'] }} - {{ $option['quantity'] }},
			@endforeach
		@endif
	</td>
	<td style="{{ $border }}">{{ $item['sku'] }}</td>
	<td style="{{ $text_right }} {{ $border }}">{{ number_format( $item['price'], 2) }}</td>
	<td style="{{ $text_right }} {{ $border }}">{{ number_format( $item['total'], 2) }}</td>
</tr>
@endforeach
<tr>
	<td style="{{ $border }}">&nbsp;</td>
	<td style="{{ $border }}">&nbsp;</td>
	<td colspan="4" style="{{ $text_center }} {{ $border }}">** {{ $print_nothing_follows }} **</td>
	<td style="{{ $border }}">&nbsp;</td>
	<td style="{{ $border }}">&nbsp;</td>
	<td style="{{ $border }}">&nbsp;</td>
</tr>

<!-- Totals -->
<tr>
	<td colspan="7" style="{{ $text_center }} {{ $border }}"><small style="{{ $text_italic }}">{{ $print_vat_message }}</small></td>
	<td style="{{ $text_bold }} {{ $text_center }} {{ $border }}">{{ $print_sub_total }}</td>
	<td style="{{ $text_right }} {{ $border }}">{{ number_format($po_info['total_price'], 2) }}</td>
</tr>
<tr>
	<td colspan="7" rowspan="2" style=" {{ $text_left }} margin: 0; {{ $border }} {{ $text_top }}">
		<small style="{{ $text_italic }}">{{ $print_special_instructions }}</small>
		{{ $po_info['comments'] }}
	</td>
	<td style="{{ $text_bold }} {{ $text_center }} {{ $border }}">{{ $print_tax }}</td>
	<td style="{{ $text_right }} {{ $border }}">0.00</td>
</tr>
<tr>
	<td style="{{ $text_bold }} {{ $text_center }} {{ $border }}">{{ $print_total }}</td>
	<td style="{{ $text_right }} {{ $border }}">{{ number_format($po_info['total_price'], 2) }}</td>
</tr>
<tr><td colspan="9">&nbsp;</td></tr>

<!-- Signees -->
<tr>
	<td colspan="3" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_ordered_by }}</td>
	<td colspan="3" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_approved_by }}</td>
	<td colspan="3" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_po_received_by }}</td>
</tr>
<tr>
	<td colspan="3" rowspan="2" style="{{ $text_center }} {{ $border }} {{ $text_bottom }}">{{ $po_info['prepared_by'] }}</td>
	<td colspan="3" rowspan="2"style="{{ $text_center }} {{ $border }} {{ $text_bottom }}">{{ $po_info['approved_by'] }}</td>
	<td colspan="3" rowspan="2" style="{{ $text_center }} {{ $border }} {{ $text_bottom }}"></td>
</tr>
<tr></tr>
<tr>
	<td colspan="3" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_date }}</td>
	<td colspan="3" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_date }}</td>
	<td colspan="3" style="{{ $black_and_white }} {{ $text_center }} {{ $border }}">{{ $print_date }}</td>
</tr>
<tr>
	<td colspan="3" style="{{ $text_center }} {{ $border }}">{{ $po_info['prepared_at'] }}</td>
	<td colspan="3" style="{{ $text_center }} {{ $border }}">{{ $po_info['approved_at'] }}</td>
	<td colspan="3" style="{{ $text_center }} {{ $border }}"></td>
</tr>
</table>